//package work.timejay.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//import work.timejay.utils.sqlEncrypt.CustomSqlFilter;
//import work.timejay.utils.sqlEncrypt.EncryptCommonUtils;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import java.io.File;
//import java.io.IOException;
//import java.net.URL;
//import java.util.Collections;
//import java.util.Enumeration;
//
///**
// * @className:EncryptConfig.java
// * @author:王文杰
// * @version:1.0.0
// * @description:TODO
// * @createTime 2024年01月29日 17:20:00
// */
//@Configuration
//@Slf4j
//public class EncryptConfig {
//
//    @Resource
//    private Environment dev;
//
//    /**
//     * 加入自定义拦截器
//     * @return
//     */
//    @ConfigurationProperties(prefix = "spring.datasource")
//    @Bean()
//    public DruidDataSource dataSource(){
//        DruidDataSource dataSource = new DruidDataSource();
//        //使用自定义拦截器 注意 不能new
//        dataSource.setProxyFilters(Collections.singletonList(new CustomSqlFilter()));
//        //dataSource.setProxyFilters(Collections.singletonList(statGwmFilter()));
//        //设置druid的重置间隔
//        dataSource.setTimeBetweenLogStatsMillis(60000);
//        return dataSource;
//    }
//
//    /**
//     * 初始化项目
//     */
//    @PostConstruct
//    public void init() {
//        String packageValue = dev.getProperty("encrypt.package");
//        String replace = packageValue.replace(".", "/");
//        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//        Enumeration<URL> resources = null;
//        try {
//            resources = classLoader.getResources(replace);
//            while (resources.hasMoreElements()) {
//                URL url = resources.nextElement();
//                File file = new File(url.getFile());
//                String middle = packageValue.replace(".", "\\");
//                int pos = file.getAbsolutePath().lastIndexOf(middle);
//                String substring = file.getAbsolutePath().substring(0, pos);
//                EncryptCommonUtils.scanPackages(file, substring);
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        log.info("初始化项目包扫描成功 ");
//    }
//}
